#ifndef __TASKQUEUE_H__
#define __TASKQUEUE_H__

#include <queue>
#include <functional>
#include <condition_variable>
#include <mutex>

using std::function;
using std::queue;
using std::condition_variable;
using std::mutex;


class TaskQueue
{
    using ElemType = function<void()>;
public:
    TaskQueue(size_t capa);
    ~TaskQueue();
    bool empty() const;
    bool full() const;
    void push(ElemType &&taskcb);
    ElemType pop();
    void wakeup();//唤醒_notEmpty处阻塞

private:
    size_t _capacity;
    queue<ElemType> _que;
    condition_variable _notEmpty;
    condition_variable _notFull;
    mutex _mutex;
    bool _wakeFlag;
};



#endif

